assume cs:code,ds:data

data segment
	db "masm"
data ends


code segment
start:			
				;将myloop中断例程移动到0:200处
				mov ax, cs
				mov ds, ax
				mov si, offset myloop_start
				mov ax, 0
				mov es, ax
				mov di, 200h
				mov cx, offset myloop_end - offset myloop_start
				cld ;设置si di递增
				rep movsb

				;设置中断向量7ch,7ch的10进制是124
				mov ax, 0
				mov es, ax
				mov word ptr es:[124 * 4], 200h ;设置ip
				mov word ptr es:[124 * 4 + 2], 0 ;设置cs

				;准备调用myloop中断例程
				mov ax, data
				mov ds, ax
				mov si, 0
				mov ax, 0B800h
				mov es, ax
				mov di, 160 * 12 + 32 * 2
				mov cx, 4 ;循环次数
				mov bx, offset s0 - offset s1 ;循环开始和结尾的位移差
s0:				mov al, ds:[si]
				mov es:[di], al
				inc di
				mov byte ptr es:[di], 42h ;红底绿字
				inc di
				inc si
				int 7ch ;进入myloop中断例程

s1:				mov ax, 4c00h
				int 21h



;自己编写的loop中断例程				
myloop_start:	push bp ;先保存bp
				mov bp, sp
				dec cx ;cx先减一
				jcxz s2 ;cx为0跳转到s2,退出中断例程
				add [bp + 2], bx ;修改栈中保存的ip，bx为位移，使用本中断例程的循环，开始和结尾的位移差
s2:				pop bp
				iret
myloop_end:		nop

code ends

end start